import { Entity, Column, PrimaryColumn, OneToMany } from 'typeorm';
import { Order } from "./order";
import { Delivery } from "./delivery";

@Entity()
export class Client {
  /**
   * Client主键，clientId，由创建时输入的简写和上一个Id的最后一个数字构成
   * @type number
   */
  @PrimaryColumn({
    length: 6
  })
  id: string;

  /**
   * Client姓名，一串4-20个字符长度的字符串，最多允许20位存储
   * @type string
   */
  @Column({
    length: 20
  })
  name: string;

  /**
   * Client地址，字符串，在数据库中不限长度。
   * @type string
   */
  @Column("text")
  address: string;

  /**
   * Client电话，字符串
   * @type string
   */
  @Column()
  phone: string;

  @OneToMany(type => Order, order => order.client)
  orders: Order[];

  @OneToMany(type => Delivery, delivery => delivery.client)
  deliveries: Delivery[];
}